//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package net.mingsoft.mdiy.action.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.mdiy.action.BaseAction;
import net.mingsoft.mdiy.util.ConfigUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Api(
        tags = {"前端-自定义模块接口"}
)
@Controller("webMdiyConfig")
@RequestMapping({"/mdiy/config"})
public class ConfigAction extends BaseAction {
    public ConfigAction() {
    }

    @ApiOperation("获取配置中的key指定value值")
    @ApiImplicitParams({@ApiImplicitParam(
            name = "configName",
            value = "配置名称",
            required = true,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "key",
            value = "配置key",
            required = true,
            paramType = "query"
    )})
    @GetMapping({"/get"})
    @ResponseBody
    public ResultData get(String configName, String key, HttpServletResponse response, HttpServletRequest request) {
        return !StringUtils.isEmpty(configName) && !StringUtils.isEmpty(key) ? ResultData.build().success(ConfigUtil.getString(configName, key)) : ResultData.build().error(this.getResString("err.empty", new String[]{this.getResString("config.name")}));
    }
}
